﻿namespace MqttSample
{
    /// <summary>
    /// mqtt callback
    /// </summary>
    public interface IMqttCallback
    {
        /// <summary>
        /// 输出数据
        /// </summary>
        Task OutEventDataAync(MqttClientOption option, CallbackData data);
    }

    /// <summary>
    /// 事件数据
    /// </summary>
    public class CallbackData
    {
        /// <summary>
        /// 类型
        /// </summary>
        public DataType Type { get; set; }

        /// <summary>
        /// 当前订阅clientid
        /// </summary>
        public string? CurrentClientId { get; set; }

        /// <summary>
        /// 当前订阅主题
        /// </summary>
        public string? Topic { get; set; }

        /// <summary>
        /// 订阅数据
        /// </summary>
        public byte[]? Data { get; set; }

        /// <summary>
        /// 信息
        /// </summary>
        public string? Message { get; set; }

        /// <summary>
        /// fire time
        /// </summary>
        public DateTimeOffset Time { get; set; } = DateTimeOffset.Now;
    }

    /// <summary>
    /// 数据类型
    /// </summary>
    public enum DataType
    {
        /// <summary>
        /// 连接
        /// </summary>
        Connect = 1,

        /// <summary>
        /// 断开
        /// </summary>
        DisConnect = 2,

        /// <summary>
        /// 数据订阅
        /// </summary>
        Subscribe = 3,

        /// <summary>
        /// 取消订阅
        /// </summary>
        UnSubscribe = 4
    }
}
